print("Введите последовательность:")
s =input()
s1,s2 = "",""
for n in s:
    if n == '(':
        s1 += n
    if n == ')':
        s2 += n
        if len(s1) > 0:
            if s1[-1] == '(':
                s1 = s1[:-1]
                s2 = s2[:-1]
    if n == '[':
        s1 += n
    if n == ']' :
        s2 += n
        if len(s1) > 0:
            if s1[-1] == '[':
                s1 = s1[:-1]
                s2 = s2[:-1]
    if n == '{':
        s1 += n
    if n== '}':
        s2 += n
        if len(s1) > 0:
            if s1[-1] == '{':
                s1 = s1[:-1]
                s2 = s2[:-1]
    if n == '<':
        s1 += n
    if n == '>' :
        s2 += n
        if len(s1) > 0:
            if s1[-1] == '<':
                s1 = s1[:-1]
                s2 = s2[:-1]
if len(s1) == 0 and len(s2) == 0 :
    print("True")
else:
    print("false")
